import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useUserStore = defineStore(
  'user',
  () => {
    // 令牌
    const jwt_token = ref('')
    // 用户信息
    const userInfo = ref({
      id: 0,
      username: '',
      nickname: '',
      avatar: ''
    })

    function doLogin(token: string, loginUserInfo: any) {
      jwt_token.value = token
      userInfo.value = loginUserInfo
    }

    return { jwt_token, userInfo }
  },
  {
    persist: true
  }
)
